package o.json;

public class JSONString extends JSONValue {
	private final String value;

	public JSONString(String value) {
		if (value == null) throw new IllegalArgumentException();

		this.value = value;
	}

	public boolean isEmpty() {
		return value.isEmpty();
	}
	public String getValue() {
		return value;
	}

	@Override
	public boolean isString() {
		return true;
	}
	@Override
	public JSONString getString() throws JSONException {
		return this;
	}

	@Override
	public boolean equals(Object object) {
		if (object == this) return true;
		if (object instanceof JSONString) {
			return equals((JSONString) object);
		}
		return false;
	}
	public boolean equals(JSONString that) {
		return this.value.equals(that.value);
	}
	@Override
	public int hashCode() {
		return value.hashCode();
	}

	@Override
	public String toString() {
		return "'"+ value +"'";
	}
}
